
<?php
include "includes/conexion.php";
include "includes/funciones.php";
function activo($li) {
	if (isset($_GET["subsec"])) {
		$acc = $_GET["subsec"]; ;
		if ($acc == $li) {
			echo "class='current'";
		}
	}
}

if (isset($_GET["borrar"])) {
	$id = $_GET["borrar"];
	$c = "delete from prv_proveedor where prv_rut=$id";
	delete($c);
	$url = $_SERVER['PHP_SELF'];
}
include "segunda_barra.php";
?>

<!-- CONTENT START -->
    <div class="grid_16" id="content">
    <!--  TITLE START  --> 
    <div class="grid_9">
    <h1 class="dashboard">Mantencion <?php
		if (isset($_GET["subsec"])) {
			echo "de " . ucfirst($_GET["subsec"]);
		}
     ?>
     <?php
     $orden="prv_corr";
     $tabla="prv_proveedor";
	 $consulta = "select * from $tabla";

	 
if(isset($_POST["do"])){
	if($_POST["do"]=="filtrar"){
				 $termino=str_replace('*', '%', $_POST["buscar"]);
$consulta.="  WHERE prv_nombre LIKE '$termino' OR prv_rut LIKE '$termino' ";
	}
	else{
		$consulta.=" order by $orden desc";}
 //echo $consulta;

	}
$_SESSION["ultima_consulta"]=$consulta;
?>
     </h1>
    </div>
    <!--RIGHT TEXT/CALENDAR
    <div class="grid_6" id="eventbox"><a href="#" class="inline_calendar">You don't have any events for today! Yay!</a>
    	<div class="hidden_calendar"></div>
    </div> 
    RIGHT TEXT/CALENDAR END-->
    <div class="clear">
    </div>
    <!--  TITLE END  -->    
    <!-- #PORTLETS START -->
    <div id="portlets">
    <!-- FIRST SORTABLE COLUMN START -->
     
      <!-- FIRST SORTABLE COLUMN END -->
      <!-- SECOND SORTABLE COLUMN START -->
 
	<!--  SECOND SORTABLE COLUMN END -->
    <div class="clear"></div>
    <!--THIS IS A WIDE PORTLET-->
    <div class="portlet">
        <div class="portlet-header fixed"><img src="images/icons/user.gif" width="16" height="16" alt="Latest Registered Users" /> Lista de proveedores registrados
        	<?php	if(isset($_POST["error"])){echo "<p class='info' id='error'><span class='info_inner'>".$_POST["error"]."</span></p>";}?></div>
		<!--FORMULARIO DE FILTRO -->
          <div id="filtro">
                <form id="frm_filtro" name ="frm_filtro" method="post" action="menu.php?sec=mantencion&subsec=proveedores">
                 <li><input type="text" name="buscar" size="25" placeholder="Buscar..." /></li>
                <li>
                    <button type="submit" id="do" name="do" value="filtrar">Filtrar</button>
                </li>
                <li>
                  <button type="submit" id="do" name="do" value="todos">Todos</button>
                </li>
            </ul>
        </form>
       </div>
        <!--END FILTRO-->
		<div class="portlet-content nopadding">
        <form action="" method="post">

          <table width="100%" cellpadding="0" cellspacing="0" id="box-table-a" summary="Employee Pay Sheet">
            <thead >
              <tr>
                 <!--<th width="34" scope="col"><input type="checkbox" name="allbox" id="allbox" onclick="checkAll()" /></th> -->
                <th width="136" scope="col">Rut</th>
                <th width="102" scope="col">DV</th>
                <th width="109" scope="col">Nombre</th>
                <th width="230" scope="col">Direccion</th>
                <th width="171" scope="col">Comuna</th>
                <th width="123" scope="col">Ciudad</th>
                <th width="90" scope="col">Telefono</th>
                <th width="90" scope="col">Email</th>
                <th width="90" scope="col">Fax</th>
                <th width="90" scope="col">Giro</th>
                <th width="90" scope="col">Acciones</th>
              </tr>
            </thead>
            <tbody">
            	<!-- fila -->
<?php

//$consulta = "select * from prv_proveedor";
$qry = mysql_query($consulta);
while ($row = mysql_fetch_row($qry)) {
	echo "
              <tr>
               <!--  <td width='34'><label>
                     <input type='checkbox' name='checkbox' id='checkbox' /> -->
                </label></td>
                <td>$row[0]</td>
                <td>$row[1]</td>
                <td>$row[3]</td>
                <td>$row[4]</td>
                <td>$row[5]</td>
                <td>$row[6]</td>
                <td>$row[7]</td>
                <td><a href='mailto:$row[8]'>$row[8]</a></td>
                <td>$row[9]</td>
                <td>$row[10]</td>
                <td width='90'></a> <a href='?sec=mantencion&subsec=proveedores&editar=$row[0]' class='edit_icon' title='Editar'></a> <a href='?sec=mantencion&subsec=proveedores&borrar=$row[0]' class='delete_icon' title='Borrar'></a></td>
              </tr>
";
}
?>              
              
             
              <tr class="footer">
              	
                
              </tr>
            </tbody>
          </table>
<a href="#login-box" class="button_ok" id="boton" ><span>Agregar</span></a><a href="mantenedores/imprimir.php?imprimir=proveedor" class="button_imprimir"><span>Imprimir</span></a>
        </form>
		</div>
      </div>
      
      <!-- pop up -->
<!--  END #PORTLETS -->  
   </div>
    <div class="clear"> </div>
<!-- END CONTENT-->    
  </div>
 